package com.example.cs342messenger;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseOpenHelper extends SQLiteOpenHelper{

	
	public DatabaseOpenHelper(Context context, String name, CursorFactory factory, int version){
		super(context, name, factory, version);
		
	}
	/*
	public DatabaseOpenHelper(Context ctx){
		//this.context = ctx;
		//DBHelper = new DatabaseHelper(context);
		super(ctx,  "Messaging", null, 1);
	}

	*/
	@Override
	public void onCreate(SQLiteDatabase db){
		String createUsers= "CREATE TABLE User "+
				"(user TEXT PRIMARY KEY NOT NULL, "+
				"pass TEXT NOT NULL);";
		String messageTable ="CREATE TABLE messages" +
				"(sender TEXT, reciever TEXT, message TEXT, time TIMESTAMP);";
		
		String savedMessages ="CREATE TABLE savemessage"+
				"(sender TEXT, reciever  TEXT, message TEXT, time TIMESTAMP);";
		
		db.execSQL(createUsers);
		db.execSQL(messageTable);
		db.execSQL(savedMessages);
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
		
	}
}